//package com.xd.springaiagent.advisor;
//
////
//// Source code recreated from a .class file by IntelliJ IDEA
//// (powered by FernFlower decompiler)
////
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.ai.chat.client.advisor.api.*;
//import org.springframework.ai.chat.model.MessageAggregator;
//import reactor.core.publisher.Flux;
//
///**
// * 自定义日志 Advisor
// * 打印 info 级别日志，只输出单次用户提示词和 AI 回复的文本
// */
//@Slf4j
//public class MyLoggerAdvisor implements CallAroundAdvisor, StreamAroundAdvisor {
//
//
//    @Override
//    public String getName() {
//        return this.getClass().getSimpleName();
//    }
//
//    @Override
//    public int getOrder() {
//        return 0;
//    }
//
//    private AdvisedRequest before(AdvisedRequest request) {
//        log.info("AI Request: {}", request.userText());
//        return request;
//    }
//
//    private void observeAfter(AdvisedResponse advisedResponse) {
//        log.info("AI Response: {}", advisedResponse.response().getResult().getOutput().getText());
//    }
//
//
//    /**
//     * 非流式调用
//     * @param advisedRequest
//     * @param chain
//     * @return
//     */
//    @Override
//    public AdvisedResponse aroundCall(AdvisedRequest advisedRequest, CallAroundAdvisorChain chain) {
//        advisedRequest = this.before(advisedRequest);
//        AdvisedResponse advisedResponse = chain.nextAroundCall(advisedRequest);
//
//        /**
//         * 使用 adviseContext 在 Advisor 链中共享状态：
//         */
//        /*// 读取上下文
//        Object value = advisedResponse.adviseContext().get("userMassage");*/
//
//
//        this.observeAfter(advisedResponse);
//        return advisedResponse;
//    }
//
//    /**
//     * 流式调用
//     * @param advisedRequest
//     * @param chain
//     * @return
//     */
//    @Override
//    public Flux<AdvisedResponse> aroundStream(AdvisedRequest advisedRequest, StreamAroundAdvisorChain chain) {
//        advisedRequest = this.before(advisedRequest);
//        Flux<AdvisedResponse> advisedResponses = chain.nextAroundStream(advisedRequest);
//        return (new MessageAggregator()).aggregateAdvisedResponse(advisedResponses, this::observeAfter);
//    }
//}
